import { Body, Controller, Get, Post, Query, UseGuards } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { Roles } from "/@/logical/adminModule/auth/roles.decorator";
import { AddSwiperDto, EditSwiperDto, GetSwiperDto } from "../dto/swiper.dto";
import { SwiperService } from "../service/swiper.service";
import { AuthEnum } from "/@/enum/auth.enum";
import { RolesGuard } from "/@/logical/adminModule/auth/roles.guard";

@ApiTags("Swiper")
@Controller("swiper") //模块路径
@UseGuards(RolesGuard)
export class SwiperController {
  constructor(private readonly swiperService: SwiperService) {
    //
  }

  @Get("getSwiperList") //请求的方式，get post
  @Roles(AuthEnum.OPERATE, AuthEnum.OPERATE_VIEW) //能访问的角色
  @ApiOperation({ summary: "获取轮播列表" })
  async getSwiperList(@Query() query: GetSwiperDto): Promise<any> {
    return this.swiperService.getSwiperList(query); //返回service的执行结果
  }

  @Post("addSwiper")
  @Roles(AuthEnum.OPERATE)
  @ApiOperation({ summary: "添加轮播" })
  async addSwiper(@Body() params: AddSwiperDto): Promise<any> {
    return this.swiperService.addSwiper(params);
  }

  @Post("editSwiper")
  @Roles(AuthEnum.OPERATE)
  @ApiOperation({ summary: "编辑轮播" })
  async editSwiper(@Body() params: EditSwiperDto): Promise<any> {
    return this.swiperService.editSwiper(params);
  }
}
